<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
 	<%@ include file="/WEB-INF/view/jQgrid.jsp"%>
</head>
<body>
<div class="container-fluid" id="main-container">
    <div id="page-content" class="clearfix">
        <div class="row-fluid">
            <div class="row-fluid">
                <!-- 检索  -->
                <div class="ibox-title" style="border-color: white;">
                    <div class="row">
                        <div class="col-sm-12" >
                            <div class="form-group form-inline" >
                                <input id="name" type="text" placeholder="请输入需求名称" class="input-sm form-control"  value="${position }">
                                <input id="id" type="hidden" value="${demandId }" />
                                <input id="companyId" type="hidden" value="${companyId }" />
                                 <a id="find_btn" type="button" class="btn btn-sm btn-primary"> 搜索</a> &nbsp;&nbsp;
                       		     <a  class="btn btn-sm btn-warning"  onclick="reset();"> 重置</a>&nbsp;&nbsp;
                       		      <a id="sub_btn" class="btn btn-sm btn-success" > 确认</a>
                             </div>
                        </div>
                    </div>
                </div>
                <!-- biaogebigin -->
                <input type="hidden" id="tempids" value="" />
		        <input type="hidden" id="tempnames" value="" />
                <div class="ibox-content" style=" padding-left: 0px; margin-top: 10px;">
                    <div class="jqGrid_wrapper">
                        <table id="table_list"></table>
                        <div id="pager_list"></div>
                    </div>
                </div>
                <!-- tableover -->
            </div>
            <!-- PAGE CONTENT ENDS HERE -->

        </div>
        <!--/row-->
    </div>
    <!--/#page-content-->
</div>
<!--/.fluid-container#main-container-->
<script type="text/javascript">
    var name = $("#name").val();
    var demandId = $("#id").val();
    var company_id = $("#companyId").val();
        $.jgrid.defaults.styleUI = "Bootstrap";
        $("#table_list").jqGrid({
            url: '<%=contextPath%>/demandEnterprise/listData',
            datatype: "json",
            postData: {'name':name,'id':demandId,'companyId':company_id}, //发送数据
            autowidth: true,
            rownumbers: true,
            shrinkToFit: true,
            mtype: "post",
            rowNum: 10,
            rowList: [10, 20, 30],
            colNames: [
			"id",
			"所属公司",
			"岗位名称",
			"岗位职能",
			"岗位产生原因",
			"工作区域",
			"对标企业经历",
			"排除企业工作的人",
			"排除区域"],
            colModel: [
			{name: "id",index: "id",hidden: true}, 
			{name:"company.name",index:"company.name",width:100},
			{name:"positionName",index:"positionName",width:100},
				{name:"positionNames",index:"positionNames",width:100},
				{name:"cause",index:"cause",width:100},
				{name:"workAreaNames",index:"workAreaNames",width:100},
				{name:"standardEnterprise",index:"standardEnterprise",width:100},
				{name:"excludePerson",index:"excludePerson",width:100},
				{name:"excludeAreaNames",index:"excludeAreaNames",width:100}],
            height: $(window).height() - 170,
            pager: "#pager_list",
            multiselect: true,//多选按钮
            //multiboxonly: true,
            viewrecords: true,
            hidegrid: false
        });
        //表格自适应高宽
        $(window).bind("resize", function () {
            var b = $(".jqGrid_wrapper").width();
            $("#table_list").setGridWidth(b);
            $("#table_list").setGridHeight($(window).height() - 170);
        })
        $("#table_list").navGrid('#pager_list', {edit: false, add: false, del: false, search: false})
        /* 判断是否有添加权限 */
        //检索
        $("#find_btn").click(function () {
        	name = $("#name").val();
        	demandId = $("#id").val();
            $("#table_list").jqGrid('setGridParam', {
                postData: {'name': name,'id':demandId}, //发送数据
                page: 1
            }).trigger("reloadGrid"); //重新载入
        });
        $("#sub_btn").click(function() {
        	var selectedIds = $("#table_list").jqGrid("getGridParam", "selarrrow");
        	var tempid="";
        	var tempname="";
        	var rowdatas;
        	for (var i = 0; i < selectedIds.length; i++) {
        		rowdatas = $("#table_list").jqGrid("getRowData",selectedIds[i]);
        		tempid  += rowdatas.id;
        		tempname +=rowdatas.positionName;
        		if(i>0){
        			alert("请选择一条数据进行推荐");
        			return;
        		}
			}
        	$("#tempids").val(tempid);
        	$("#tempnames").val(tempname);
        	top.Dialog.close();
		});
       function reset() {
		$("#name").val('');
		$("#id").val('');
       }
</script>
</body>
</html>

